Q and A 2025
What is data structure?
Ans: Data structure is a method to store and organize data such that accessing and manipulating data becomes easily.
What are the different types of data structure?
Ans: Two major types of data structure are:
Stack, Queue and linked lists are linear data structures and Tree, graphs are non-linear Data structure.
What is stack and what are the possible operations with stack?
Ans: Stack is a linear data structure with one end from which insertion and deletion of data is done. That end is termed as “TOP”, top is an integer value which is increased by one to insert element and decremented by one to delete element. In stack last element inserted is the first element to be removed so, it is called Last In First Out (LIFO). Possible operations with stack are
What is queue and what are the possible operations with queue?
Ans: Queue is a linear data structure with two ends for inserting and removing elements. Those two ends are termed “REAR” and “FRONT” of queue. In queue first element inserted is the first element to be removed so, it is also known as First In First Out (FIFO) data structure.
Possible operations with queue are:
What is circular queue?
Ans: Circular queue is a queue in which rear can be incremented to insert new elements to occupy empty space remained after removing elements from the queue.
Explain priority queue.
Ans: Priority queue is a queue in which elements are removed based on the priority of the elements. Elements of the queue are given priority and priority with highest priority is removed first.
Write a module to insert an element to stack.
Let\’s suppose stk be an integer array of size 20 and ele be an element to insert into the stack. Then the module to insert element to stack will be as follows:
public void push(int ele, int[] stk){ if(isEmpty(stk)){ stk[top] = ele; }else{ System.out.println(\”Stack is full\”); }
Write module to remove element from stack.
Let’s suppose que be an integer queue of size twenty. Then the module to insert element to queue will be as follows:
public void pop(){ if(isEmpty(que)){ int x = que[front]; ++front; }else{ System.out.println(“Queue is Empty!”); } }